package ua.com.globallogic.basecamp.krasnyanskiy.anagrams.ioutils;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class AnagramFileReader {
    FileValidator validator;

    public AnagramFileReader() {
        this.validator = new FileValidator();
    }

    public String read(File file) throws IOException, FileValidationException {
        validator.validate(file);

        StringBuilder sb = new StringBuilder();
        Scanner scanner = new Scanner(file);

        while (scanner.hasNext()){
            String text = scanner.nextLine();
            sb.append(text);
        }
        return sb.toString();
    }
}
